package com.pl.entity;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pl.DateFormat.DateConverter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * @version 1.0
 * @Author 小胤
 * @Date 2024/4/25 20:06
 * @注释
 */
public class Student {

    private int id;
    @ExcelProperty(value = "学生姓名")
    @ColumnWidth(value =30)
    private String name;
    @ExcelProperty(value = "学生年龄")
    @ColumnWidth(value =30)
    private int age;
    @ExcelProperty(value = "学生性别")
    @ColumnWidth(value =30)
    private String sex;
    // 生日 年月日
    // 将前端提交的字符串时间（yyyy-MM-dd） 转换为 Date类型
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    //  @JsonFormat  1将接收得到的json数据中对应birthday 时间转换 java中Date
    //               2.处理器方法返回json数据时 将java中Date  转换为对应的字符串时间   yyyy-MM-dd
    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8") // 当前注解只对提交的json 数据有效，对提交的键值对没有效果
    @ExcelProperty(value = "学生生日" ,converter= DateConverter.class)
    @ColumnWidth(value =30)
    private Date birthday;

    public Student() {
    }

    public int getId() {
        return id;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                ", birthday=" + birthday +
                '}';
    }
}

